<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>考试系统首页</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="./index.css">
  </head>
  
  <body>
  <%  
        //驱动程序名   
        String driverName = "com.mysql.jdbc.Driver";  
        //数据库用户名   
        String userName = "root";  
        //密码   
        String userPasswd = "root123";  
        //数据库名   
        String dbName = "examsystem";  
        //联结字符串   
        String url = "jdbc:mysql://localhost:3306/" + dbName + "?user="  
                + userName + "&password=" + userPasswd;  
        Class.forName("com.mysql.jdbc.Driver").newInstance();  
        Connection connection = DriverManager.getConnection(url);  
        Statement statement = connection.createStatement();  
        String sql = "SELECT * FROM student";  
        ResultSet rs = statement.executeQuery(sql);  
    %>  
    <div class="div1">
        <div class="div2">
            <a href="#"><button style="margin-top:30px;">初级</button></a>
            <a href="#"><button>中级</button></a>
            <a href="#"><button>高级</button></a>
            <a href="register.html"><button>注册</button></a>
            <a href="login.html"><button>登录</button></a>
            <a href="#"><button>退出系统</button></a>
        </div>
        <div class="div3">
            <div class="div_top">
                <h1>考试系统</h1>
                <input id="search" type="text" placeholder="请输入要搜索的关键字">
                <input id="but" type="button" value="搜索"/>
            </div>
            <div class="div_bottom">
                <table border="1">
                    <tr>
                        <th></th>
                        <th>名字</th>
                        <th>项目</th>
                        <th>成绩</th>
                        <th>总分</th>
                    </tr>
                    <%
                    	while(rs.next()){
                    %>
                    <tr>
                        <th>
                        	<%
                        		out.print(rs.getInt(1));
                        	%>
                        </th>
                        <td>
                        	<%
                        		out.print(rs.getString(2));
                        	%>
                        </td>
                        <td>
							<%
                        		out.print(rs.getString(3));
                        	%>
						</td>
                        <td>
                        	<%
                        		out.print(rs.getString(4));
                        	%>
                        </td>
                        <%
                    	};
                    	%>
                        <td rowspan="5">
                        <%%>
                        </td>
                    </tr>
                    
                    
                </table>
            </div>
        </div>
        <div class="div4"></div>
    </div>
    <%
    connection.close();
    statement.close();
    rs.close();
    %>
  </body>
</html>
